<template>
	<view class="h-full" style="color: #9FA6B5;">
		<view id="headerHeight" class="p-4 text-white">
			<view class="flex m-auto rounded-full" style="width: 400rpx;background-color: #484859;">
				<view class="flex-1 py-1 text-center" :class="{'active':active==0}" @click="active=0">{{$t('notice.xiaoxi')}}</view>
				<view class="flex-1 py-1 text-center" :class="{'active':active==1}" @click="active=1">{{$t('notice.gonggao')}}</view>
			</view>
		</view>
		<view v-if="headerHeight">
			<scroll-view style="width: 100%;" :style="{height:headerHeight}" scroll-y="true" refresher-enabled="true" :refresher-threshold="100" :refresher-triggered="refresher.triggered"
			refresher-background="#0d0d0d" @refresherrefresh="onRefresh">
				<view class="p-4">
					<!-- 消息 -->
					<template v-if="active==0">
						<view class="flex justify-between items-center w-full p-4 box-border rounded-xl" style="background-color: #22222d;"
						@click="clickItem('/pages/template/msgDetail/msgDetail')">
							<view class="flex-1">
								<view class="text-white">注册成功</view>
								<view>2025-04-05 10:28:09 AM</view>
							</view>
							<u-icon name="arrow-right" color="#999" size="16"></u-icon>
						</view>
					</template>
					<!-- 公告 -->
					<template v-if="active==1">
						<view class="flex justify-between items-center w-full p-4 box-border rounded-xl" style="background-color: #22222d;" 
						@click="clickItem('/pages/template/noticeDetail/noticeDetail')">
							<view class="flex-1">
								<view class="text-white">BTCMax開啟全球新年狂歡周活動公告</view>
								<view>2025-04-05 10:28:09 AM</view>
							</view>
							<u-icon name="arrow-right" color="#999" size="16"></u-icon>
						</view>
					</template>
					<u-loadmore :status="loadmore" />
				</view>
					
			</scroll-view>
		</view>
		
	</view>
</template>

<script>
	import {
		mapGetters,
		mapActions
	} from 'vuex'
	export default {
		computed: {
			...mapGetters(['userInfo', 'api', 'config']),
		},
		data() {
			return {
				active:0,
				headerHeight:'',
				// 下拉刷新
				refresher:{
					_freshing:false,
					triggered:false
				},
				// 加载更多
				loadmore:'nomore',//loading / nomore
				
			}
		},
		onLoad(op) {
		},
		onReady() {
			const query = uni.createSelectorQuery().in(this);
			query.select("#headerHeight").boundingClientRect((data) => {
			    console.log("得到布局位置信息" + JSON.stringify(data),this.$u.sys());
				this.headerHeight = this.$u.sys().windowHeight - data.height +'px'
				console.log(this.headerHeight);
			}).exec();
		},
		methods: {
			// 点击
			clickItem(path,item){
				uni.navigateTo({
					url: `${path}?id=11`,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			},
			//下拉刷新
			onRefresh(){
				if (this.refresher._freshing) return;  
				this.refresher._freshing = true;  
				if (!this.refresher.triggered)//界面下拉触发，triggered可能不是true，要设为true  
				this.refresher.triggered = true;  
				setTimeout(() => {
					this.refresher.triggered = false;
					this.refresher._freshing = false;
				},1000)
			},
		}
	}
</script>

<style lang="scss">
	.active{
		background-color: #fff;color: #000;border-radius: 100px;
	}
</style>